package shoe_maker;

import java.util.*;
import java.io.*;
/*
 * Name: Shoemaker's Problem
 * Problem ID: 110405
 * Date: 4/16/2012 2:33 PM
 * By: Kenny Chong
 */
class Main implements Runnable
{
	static String ReadLn(int maxLength) 
    {
        byte line[] = new byte[maxLength];
        int length = 0;
        int input = -1;
        try {
            while (length < maxLength) {
                input = System.in.read();
                if ((input < 0) || (input == '\n'))
                    break;
                line[length++] += input;
            }

            if ((input < 0) && (length == 0))
                return null;
            return new String(line, 0, length);
        } catch (IOException e) {
            return null;
        }
    }

	public static void main(String [] args)
	{
		Main myMain = new Main();
		myMain.run();
	}
	
	public void run()
	{
		new ShoeMaker().run();
	}
}

class ShoeMaker implements Runnable
{
	static final int MAX_LENGTH = 1050;
	
	public void run()
	{
		// Read number of test cases.
		int testCases = Integer.parseInt(Main.ReadLn(MAX_LENGTH).trim());
		
		// Read blank line.
		Main.ReadLn(MAX_LENGTH);
		
		for (int i = 0; i < testCases; i++)
		{
			// Consecutive cases, read blank line.
			if (i != 0)
			{
				System.out.println();
			}
			
			// Read number of jobs.
			int numOfJobs = Integer.parseInt(Main.ReadLn(MAX_LENGTH).trim());
			
			// An array to hold job (days/penalty cost)
			String [] jobStats = new String[numOfJobs + 1];
			
			for (int j = 1; j < jobStats.length; j++)
			{
				String line = Main.ReadLn(MAX_LENGTH).trim();
				
				jobStats[j] = line;
			}
			
			helpShowMaker(jobStats);
			
		} while (Main.ReadLn(MAX_LENGTH) != null); 
	}
	
	public void helpShowMaker(String [] jobStats)
	{
		ArrayList<Double> stuffTwo = new ArrayList<Double>();
		ArrayList<Double> temp = new ArrayList<Double>();
		
		stuffTwo.add(-1.1);
		temp.add(-1.1);
		
		for (int i = 1; i < jobStats.length; i++)
		{
			String value = jobStats[i];
			
			// Locate position of " " in value
			int blankPos = value.indexOf(" ");
			
			// Retrieve days required for job.
			double daysRequired = Double.parseDouble(value.substring(0, blankPos));
			
			// Retrieve penalty for not completing job for that day.
			double penaltyCost = Double.parseDouble(value.substring(blankPos + 1));
			
			// Divide day by penalty.
			double result = daysRequired/penaltyCost;
		
			stuffTwo.add(result);
			temp.add(result);
		}
		
		Collections.sort(stuffTwo);
		
		printResults(stuffTwo, temp);
	}
	
	public void printResults(ArrayList<Double> sorted, ArrayList<Double> original)
	{
		String value = "";
		
		for (int i = 1; i < sorted.size(); i++)
		{
			Double result = sorted.get(i);
			
			for (int j = 1; j < original.size(); j++)
			{
				Double search = original.get(j);
				
				if (result.equals(search))
				{
					value += j + " ";
					
					// Refer so we don't use it again.
					original.set(j, -1.0);
				}
			}
		}
		
		System.out.println(value.trim());
	}
}